package net.osc.addrpsr.models;

/**
 * User: ken
 * Date: 13-7-24
 */
public class Address {

    //省
    public String province;

    //市
    public String city;

    //县区
    public String district;

    //街道
    public String road;

    //号码
    public String roadNo;

    //住宅小区
    public String building;

    //小区号码
    public String buildingNo;

    //兴趣点
    public String poi;

    public Address() { }

    public Address(String province, String city, String district, String road, String roadNo, String building, String buildingNo) {
        this.province = province;
        this.city = city;
        this.district = district;
        this.road = road;
        this.roadNo = roadNo;
        this.building = building;
        this.buildingNo = buildingNo;
    }

    public Address province(String province) {
        this.province = province;
        return this;
    }

    public Address city(String city) {
        this.city = city;
        return this;
    }

    public Address district(String district) {
        this.district = district;
        return this;
    }

    public Address road(String street) {
        this.road = street;
        return this;
    }

    public Address roadNo(String streetNo) {
        this.roadNo = streetNo;
        return this;
    }

    public Address building(String building) {
        this.building = building;
        return this;
    }

    public Address buildingNo(String buildingNo) {
        this.buildingNo = buildingNo;
        return this;
    }

    public Address poi(String poi) {
        this.poi = poi;
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) { return true; }
        if (o == null || getClass() != o.getClass()) { return false; }

        Address address = (Address) o;

        if (building != null ? !building.equals(address.building) : address.building != null) {
            return false;
        }
        if (buildingNo != null ? !buildingNo.equals(address.buildingNo) : address.buildingNo != null) {
            return false;
        }
        if (city != null ? !city.equals(address.city) : address.city != null) { return false; }
        if (district != null ? !district.equals(address.district) : address.district != null) {
            return false;
        }
        if (province != null ? !province.equals(address.province) : address.province != null) {
            return false;
        }
        if (road != null ? !road.equals(address.road) : address.road != null) { return false; }
        if (roadNo != null ? !roadNo.equals(address.roadNo) : address.roadNo != null) { return false; }

        return true;
    }

    @Override
    public int hashCode() {
        int result = province != null ? province.hashCode() : 0;
        result = 31 * result + (city != null ? city.hashCode() : 0);
        result = 31 * result + (district != null ? district.hashCode() : 0);
        result = 31 * result + (road != null ? road.hashCode() : 0);
        result = 31 * result + (roadNo != null ? roadNo.hashCode() : 0);
        result = 31 * result + (building != null ? building.hashCode() : 0);
        result = 31 * result + (buildingNo != null ? buildingNo.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Address{" +
            "province='" + province + '\'' +
            ", city='" + city + '\'' +
            ", district='" + district + '\'' +
            ", road='" + road + '\'' +
            ", roadNo='" + roadNo + '\'' +
            ", building='" + building + '\'' +
            ", buildingNo='" + buildingNo + '\'' +
            '}';
    }
}
